﻿-- [CategoryItems]
CREATE TABLE [dbo].[CategoryItems](
	[Name] [nvarchar](50) NOT NULL,
	[Groups] [nvarchar](200) NULL,
	[LinkUrl] [nvarchar](200) NULL,
	[ImageUrl] [nvarchar](200) NULL,
	[Order] [int] NOT NULL,
	[CategoryItemName] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
;

ALTER TABLE [dbo].[CategoryItems]  WITH CHECK ADD  CONSTRAINT [CategoryItem_Parent] FOREIGN KEY([CategoryItemName])
REFERENCES [dbo].[CategoryItems] ([Name])
;

ALTER TABLE [dbo].[CategoryItems] CHECK CONSTRAINT [CategoryItem_Parent]
;

-- [CategoryProperties]
CREATE TABLE [dbo].[CategoryProperties](
	[CategoryItemName] [nvarchar](50) NOT NULL,
	[PropertyName] [nvarchar](50) NOT NULL,
	[DataType] [nvarchar](50) NULL,
	[Editor] [nvarchar](50) NULL,
	[Order] [int] NOT NULL,
	[DefaultValue] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[CategoryItemName] ASC,
	[PropertyName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
;

ALTER TABLE [dbo].[CategoryProperties]  WITH CHECK ADD  CONSTRAINT [CategoryProperty_CategoryItem] FOREIGN KEY([CategoryItemName])
REFERENCES [dbo].[CategoryItems] ([Name])
;

ALTER TABLE [dbo].[CategoryProperties] CHECK CONSTRAINT [CategoryProperty_CategoryItem]
;